<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改引流政策信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-policy-edit" th:object="${teamPolicy}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="type" th:field="*{type}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">增量政策编号：</label>
                <div class="col-sm-8">
                    <input name="policyId"   readonly   class="form-control"  th:field="*{policyId}" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">政策名称：</label>
                <div class="col-sm-8">
                    <input name="policyName" th:field="*{policyName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">政策比例：</label>
                <div class="col-sm-8">
                    <input name="policyValue" th:field="*{policyValue}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">引流档：</label>
                <div class="col-sm-8">
                    <select name="policyStage"  th:field="*{policyStage}" class="form-control m-b" >
                        <option value="">所有</option>
                        <option th:selected="${policyStage == '1'}" value="1">1档</option>
                        <option th:selected="${policyStage == '2'}" value="2">2档</option>
                        <option th:selected="${policyStage == '3'}" value="3">3档</option>
                        <option th:selected="${policyStage == '4'}" value="4">4档</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="policyStage"  th:field="*{status}" class="form-control m-b">
                        <option th:selected="${status == '1'}" value="1">正常</option>
                        <option th:selected="${status == '0'}" value="0">关停</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">团队类型：</label>
                <div class="col-sm-8">
                    <select name="teamType" id="teamType" th:field="*{teamType}"  onchange="rewardTypes(this)" class="form-control m-b">
                        <option th:selected="${teamType == '1'}" value="1">老团</option>
                        <option th:selected="${teamType == '2'}" value="2">新团</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">团奖励类型：</label>
                <div class="col-sm-8">
                    <select name="rewardType" id="rewardType" th:field="*{rewardType}" class="form-control m-b">
                        <option th:selected="${rewardType == '4'}" value="4">电签</option>
                        <option th:selected="${rewardType == '1'}" value="1">传统</option>
                        <option th:selected="${rewardType == '5'}" value="5">GB传统</option>
                        <option th:selected="${rewardType == '7'}" value="5">GB电签二</option>

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始区间(人数)：</label>
                <div class="col-sm-8">
                    <input name="policyCondition" th:field="*{policyCondition}"  onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束区间(人数)：</label>
                <div class="col-sm-8">
                    <input name="policyConditionEnd" th:field="*{policyConditionEnd}" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate"  th:field="*{startDate}"   class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDate"  th:field="*{endDate}"   class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "team/policy";
        $("#form-policy-edit").validate({
            focusCleanup: true
        });

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-policy-edit').serialize());
            }
        }

        if($("#teamType").val() != 2){
            $("#rewardType").attr("disabled","disabled")
        }

        function rewardTypes(type) {
            if(type.value == 2){
                $("#rewardType").removeAttrs("disabled")
            }else{
                $("#rewardType").attr("disabled","disabled")
            }
        }

    </script>
</body>
</html>
